home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_11_1986_Transactor_Publishing.d64 / screenboard src (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  7KB  |  381 lines

  1. 100 sys700
  2. 110 ;      "screenboard"
  3. 120 ;  joystick-controlled on-screen
  4. 130 ;  keyboard
  5. 140 ;
  6. 150 ;original program by david tomblin
  7. 160 ; this version jan86 -cz
  8. 170 ;
  9. 180 ;           from
  10. 190 ;      "[212]he [212]ransactor"
  11. 200 ;
  12. 210 ;
  13. 220 .opt oo
  14. 230 *=$c000
  15. 240 ;
  16. 250 chrout  =$ffd2
  17. 260 plot    =$fff0
  18. 270 screen  =$fb
  19. 280 joymask =$fd
  20. 290 temp    =$fe
  21. 300 temp2   =$ff
  22. 310 xadd    =$8b
  23. 320 joy =56320
  24. 330 ;
  25. 340 jmp start
  26. 350 ;
  27. 360 colour .byte 14 ;screenboard colour
  28. 370 sindex  .byte 0 ;screen index
  29. 380 rvschar .byte 0
  30. 390 movflg  .byte 0
  31. 400 keyflags =*
  32. 410 .byte 0 ;shift off/on/lock
  33. 420 .byte 0 ;ctrl off/on/lock
  34. 430 .byte 0 ;commdr off/on/lock
  35. 440 togcnt  .byte 0
  36. 450 tog2    .byte 0
  37. 460 flagim  .byte 0
  38. 470 stopflg .byte 0
  39. 480 olkvec  .word 0
  40. 490 olstop  .word 0
  41. 500 ;
  42. 510 start =*
  43. 520 sei
  44. 530 lda #<irqrtn  ;irq vector
  45. 540 sta $0314
  46. 550 lda #>irqrtn
  47. 560 sta $0315
  48. 570 ;save keyboard vector
  49. 580 lda $028f
  50. 590 sta olkvec
  51. 600 lda $0290
  52. 610 sta olkvec+1
  53. 620 ;change the stop vector
  54. 630 lda $0328
  55. 640 sta olstop
  56. 650 lda $0329
  57. 660 sta olstop+1
  58. 670 lda #<newstop
  59. 680 sta $0328
  60. 690 lda #>newstop
  61. 700 sta $0329
  62. 710 cli
  63. 720 rts
  64. 730 ;
  65. 740 ;
  66. 750 newkbd =* ;new keyboard setup rtn
  67. 760 lda flagim ;shift/c=/ctrl
  68. 770 sta 653
  69. 780 jmp (olkvec)
  70. 790 ;
  71. 800 ;
  72. 810 newstop =*
  73. 820 lda stopflg
  74. 830 beq nostop
  75. 840 sta $91
  76. 850 lda #0
  77. 860 sta stopflg
  78. 870 nostop =*
  79. 880 jmp (olstop)
  80. 890 ;
  81. 900 ;
  82. 910 irqrtn =*
  83. 920 jsr drawscrn ;draw screenboard
  84. 930 sec
  85. 940 jsr plot   ;check cursor pos
  86. 950 cpx #6     ;see if it's in scrnbrd
  87. 960 bcs crsok  ;no it isn't
  88. 970 ;yes it is, move cursor down
  89. 980 ldx #6
  90. 990 clc
  91. 1000 jsr plot
  92. 1010 crsok =*
  93. 1020 jsr scmove ;scrnbd cursor move
  94. 1030 jmp $ea31
  95. 1040 rts
  96. 1050 ;
  97. 1060 ;
  98. 1070 scmove =* ;move sc cursor row, col
  99. 1080 lda joy
  100. 1090 and #31
  101. 1100 eor #31
  102. 1110 sta joymask
  103. 1120 bne scm0   ;stick moved
  104. 1130 lda #0
  105. 1140 sta movflg
  106. 1150 jmp nostor
  107. 1160 scm0 =*
  108. 1170 lda movflg ;moved last time
  109. 1180 bne nostor
  110. 1190 lda #1
  111. 1200 sta movflg
  112. 1210 lda #16     ;fire button bit
  113. 1220 bit joymask
  114. 1230 bne keypush ;enter key
  115. 1240 lda joymask
  116. 1250 and #1   ;check up
  117. 1260 beq scm1 ;not up, check down
  118. 1270 ldx #-40 ;up, subtract 40
  119. 1280 scm1 =*
  120. 1290 lda joymask
  121. 1300 and #2   ;check down
  122. 1310 beq scm2 ;not down, check left
  123. 1320 ldx #40  ;down, add 40
  124. 1330 scm2 =*
  125. 1340 lda joymask
  126. 1350 and #4   ;check left
  127. 1360 beq scm3 ;not left, check right
  128. 1370 lda sindex
  129. 1380 cmp #120
  130. 1390 bcc sub2 ;subtract 2 for top rows
  131. 1400 ldx #-4  ;subtract 4 for bottom 2
  132. 1410 jmp scm3
  133. 1420 sub2 =*
  134. 1430 ldx #-2   ;left, subtract 2
  135. 1440 scm3 =*
  136. 1450 lda joymask
  137. 1460 and #8    ;check right
  138. 1470 beq scm4  ;not right
  139. 1480 lda sindex
  140. 1490 cmp #120
  141. 1500 bcc add2
  142. 1510 ldx #4
  143. 1520 jmp scm4
  144. 1530 add2 =*
  145. 1540 ldx #2
  146. 1550 ;
  147. 1560 scm4 =*
  148. 1570 stx xadd
  149. 1580 lda sindex
  150. 1590 clc
  151. 1600 adc xadd
  152. 1610 bpl stornew  ;keep sb cursor
  153. 1620 cmp #200
  154. 1630 bcs nostor   ;in bounds
  155. 1640 stornew =*
  156. 1650 sta sindex
  157. 1660 sta rvschar
  158. 1670 cmp #120
  159. 1680 bcc nostor
  160. 1690 and #%11111100
  161. 1700 sta rvschar  ;last 2 rows in 4s
  162. 1710 nostor =*
  163. 1720 rts
  164. 1730 ;
  165. 1740 ;
  166. 1750 keypush =* ;enter key
  167. 1760 lda sindex
  168. 1770 cmp #120   ;"top 3 rows?
  169. 1780 bcs kps1   ;no
  170. 1790 lsr a      ;yes, just divide by 2
  171. 1800 jmp kps2
  172. 1810 kps1 [178][172]
  173. 1820 ;in bot[164]m 3 rows
  174. 1830 sec
  175. 1840 sbc #120
  176. 1850 lsr a
  177. 1860 lsr a
  178. 1870 clc
  179. 1880 adc #k[195]
  180. 1890 kps2 [178][172]
  181. 1900 ;
  182. 1910 tax
  183. 1920 lda keys,x  ;[161] key from table
  184. 1930 cmp #249
  185. 1940 bcs special ;special character
  186. 1950 n[176]mc [178][172]    ;n[176]mal character
  187. 1960 cpx #37     ;check, alphanumerics
  188. 1970 bcs kbuf    ;no, use kbd buffer
  189. 1980 ;yes, use cus[164]m keyboard trap
  190. 1990 lda keycodes,x ;[161] key code
  191. 2000 sta 203     ;last key
  192. 2010 jsr [162]kbd  ;[153] the character
  193. 2020 jsr kill[164]g ;kill shft[173]ctrl[173]comm
  194. 2030 rts
  195. 2040 ;
  196. 2050 kbuf [178][172]
  197. 2060 ldy 198     ;# chars in buffer
  198. 2070 cpy 649     ;max buffer size
  199. 2080 bcs kbuf1   ;buffer full
  200. 2090 lda keys,x  ;[161] key from table
  201. 2100 sta 631,y   ;put in kbd buffer
  202. 2110 inc 198     ;inc[143]ent buf pointer
  203. 2120 kbuf1 [178][172]
  204. 2130 jsr kill[164]g
  205. 2140 rts
  206. 2150 ;
  207. 2160 ;
  208. 2170 special [178][172] ;h[175]le special chars
  209. 2180 cmp #249   ;[144] key
  210. 2190 bne spl1
  211. 2200 lda #$7f
  212. 2210 sta [144]flg
  213. 2220 rts
  214. 2230 ;
  215. 2240 spl1 [178][172]
  216. 2250 sec
  217. 2260 sbc #250 ;must be sh[139]t[173]ctrl[173]comm
  218. 2270 lsr a
  219. 2280 tax
  220. 2290 lda #1
  221. 2300 adc #0
  222. 2310 sta temp2 ;1 [139] c set, 2 [139] [156]
  223. 2320 lda keyflags,x
  224. 2330 e[176] temp2 ;switch [145][173]off [176]
  225. 2340 [175] temp2 ; lok[173]off [164]ggle
  226. 2350 sta keyflags,x
  227. 2360 ;
  228. 2370 makimag [178][172] ;set up key image
  229. 2380 lda #0
  230. 2390 sta flagim
  231. 2400 ldx keyflags
  232. 2410 beq nk1
  233. 2420 [176]a #1
  234. 2430 nk1 [178][172]
  235. 2440 ldx keyflags[170]1
  236. 2450 beq nk2
  237. 2460 [176]a #4
  238. 2470 nk2 [178][172]
  239. 2480 ldx keyflags[170]2
  240. 2490 beq nk3
  241. 2500 [176]a #2
  242. 2510 nk3 [178][172]
  243. 2520 sta flagim
  244. 2530 rts
  245. 2540 ;
  246. 2550 ;
  247. 2560 kill[164]g [178][172] ;kill 1[171]time key flags
  248. 2570 ldx #2
  249. 2580 kil1 [178][172]
  250. 2590 lda keyflags,x
  251. 2600 [175] #2
  252. 2610 sta keyflags,x
  253. 2620 dex
  254. 2630 bpl kil1
  255. 2640 jsr makimag
  256. 2650 rts
  257. 2660 ;
  258. 2670 ;
  259. 2680 drawscrn [178][172]  ;draw screenboard
  260. 2690 lda 648  ;screen page
  261. 2700 sta screen[170]1
  262. 2710 lda #0
  263. 2720 sta screen
  264. 2730 sta [164]gcnt
  265. 2740 sta [164]g2
  266. 2750 ldx #0
  267. 2760 ldy #0
  268. 2770 dr1 [178][172]
  269. 2780 lda #32
  270. 2790 sta (screen),y
  271. 2800 lda keys,x
  272. 2810 [175] #63
  273. 2820 cpy rvschar ;check [129] revers chr
  274. 2830 bne n[176]vs
  275. 2840 [176]a #128    ;set high bit [164] rvrs
  276. 2850 n[176]vs [178][172]
  277. 2860 iny
  278. 2870 sta (screen),y
  279. 2880 lda colour
  280. 2890 sta $d800,y
  281. 2900 iny
  282. 2910 inx
  283. 2920 cpx #k[195]
  284. 2930 bcc dr1
  285. 2940 ;
  286. 2950 ; [153] bot[164]m two kbd rows
  287. 2960 ldx #0        ;character counter
  288. 2970 dr2 [178][172]
  289. 2980 lda xkeys,x
  290. 2990 cmp #255     ;[164]ggles
  291. 3000 bne [168]og
  292. 3010 jsr draw[164]g  ;[153] off,[145],[176] lok
  293. 3020 [168]og [178][172]
  294. 3030 [175] #63
  295. 3040 sta temp
  296. 3050 lda rvschar  ;check highlight chr
  297. 3060 cmp #120
  298. 3070 bcc n[176]vs2   ;n[145]e [164] highlight
  299. 3080 tya
  300. 3090 clc
  301. 3100 sbc rvschar  ;highlight
  302. 3110 cmp #3       ; three characters
  303. 3120 bcs n[176]vs2   ; [139] opti[145]
  304. 3130 lda temp     ; is selected
  305. 3140 [176]a #128
  306. 3150 sta temp
  307. 3160 n[176]vs2 [178][172]
  308. 3170 lda temp
  309. 3180 sta (screen),y
  310. 3190 lda colour
  311. 3200 sta $d800,y
  312. 3210 iny
  313. 3220 inx
  314. 3230 cpx #xk[195] ;# of chars
  315. 3240 bmi dr2
  316. 3250 ;
  317. 3260 ;underline keyboard
  318. 3270 ldx #40  ;[153] 40 chars
  319. 3280 dr3 [178][172]
  320. 3290 lda #64  ;underline char
  321. 3300 sta (screen),y
  322. 3310 lda colour
  323. 3320 sta $d800,y
  324. 3330 iny
  325. 3340 dex
  326. 3350 bne dr3
  327. 3360 rts
  328. 3370 ;
  329. 3380 ;
  330. 3390 draw[164]g [178][172]
  331. 3400 ;[153] off, [145], [176] lock message
  332. 3410 txa
  333. 3420 pha
  334. 3430 ldx [164]gcnt ;0[178]shft, 1[178]ctrl, 2[178]com
  335. 3440 lda keyflags,x ;off, [145], [176] lok
  336. 3450 asl a
  337. 3460 asl a  ;x4 [164] po[181] [164] [164]gtext
  338. 3470 clc
  339. 3480 adc [164]g2
  340. 3490 tax
  341. 3500 lda [164]gtext,x
  342. 3510 sta temp
  343. 3520 inc [164]g2
  344. 3530 lda [164]g2
  345. 3540 cmp #3
  346. 3550 bcc tgl
  347. 3560 inc [164]gcnt
  348. 3570 lda #0
  349. 3580 sta [164]g2
  350. 3590 tgl [178][172]
  351. 3600 pla
  352. 3610 tax
  353. 3620 lda temp
  354. 3630 rts
  355. 3640 ;
  356. 3650 ;
  357. 3660 keys [178][172]
  358. 3670 .[198] "abcdefghijklmnopqrs "
  359. 3680 .[198] "tuvwxyz0123456789[] "
  360. 3690 .byte 33,34
  361. 3700 .[198] "#$%&'(),.?:;<=>@^ "
  362. 3710 k[195] [178][172][171]keys
  363. 3720 ctrlchrs [178][172]
  364. 3730 .byte 145,17,157,29,148,20,19,147,43,45
  365. 3740 .byte 13,249,250,251,252,253,254,255
  366. 3750 .[198] "*/"
  367. 3760 ;
  368. 3770 xkeys [178][172]
  369. 3780 .[198] " cup cdn clf crt ins del hom clr  +  -  "
  370. 3790 .[198] " rtn stp shf:(NULL)(NULL)(NULL) ctl:(NULL)(NULL)(NULL) com:(NULL)(NULL)(NULL)  *  /  "
  371. 3800 xk[195] [178][172][171]xkeys
  372. 3810 ;
  373. 3820 [164]gtext .[198] "off on  lok "
  374. 3830 ;
  375. 3840 x40 .byte 0,40,80,120,160
  376. 3850 ;
  377. 3860 keycodes [178][172]
  378. 3870 .byte 10,28,20,18,14,21,26,29,33,34
  379. 3880 .byte 37,42,36,39,38,41,62,17,13,60,22,30,31,9
  380. 3890 .byte 23,25,12,35,56,59,8,11,16,19,24,27,32
  381.